package com.atguigu.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author xiaolong
 * @version 1.0
 * @description: TODO
 * @date 2021/9/7 19:28
 */
@RestController
@Slf4j
public class OrderZKController {

    //通过服务名去调用zookeeper中管道注册的服务名对应的端口
    public static final String INVOKE_URL = "http://cloud-provider-payment";

    //restTemplate是springboot对httpclient的封装
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping(value = "/consumer/payment/zk")
    public String paymentInfo() {
        /**
         * postForObject 提供post请求  payment默认传参是json类型
         * @param1 URL 访问http请求
         * @param2 参数
         * @param3 返回值
         */
        String result = restTemplate.getForObject(INVOKE_URL + "/payment/zk", String.class);

        return result;
    }

}
